import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/order_model.dart';

OrderModel $OrderModelFromJson(Map<String, dynamic> json) {
  final OrderModel orderModel = OrderModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    orderModel.id = id;
  }
  final String? orderNo = jsonConvert.convert<String>(json['order_no']);
  if (orderNo != null) {
    orderModel.orderNo = orderNo;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    orderModel.quantity = quantity;
  }
  final double? totalPrice = jsonConvert.convert<double>(json['total_price']);
  if (totalPrice != null) {
    orderModel.totalPrice = totalPrice;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    orderModel.status = status;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    orderModel.refundStatus = refundStatus;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    orderModel.createdAt = createdAt;
  }
  final double? freight = jsonConvert.convert<double>(json['freight']);
  if (freight != null) {
    orderModel.freight = freight;
  }
  final int? pointsNum = jsonConvert.convert<int>(json['points_num']);
  if (pointsNum != null) {
    orderModel.pointsNum = pointsNum;
  }
  final int? pointsPrice = jsonConvert.convert<int>(json['points_price']);
  if (pointsPrice != null) {
    orderModel.pointsPrice = pointsPrice;
  }
  final double? amountNum = jsonConvert.convert<double>(json['amount_num']);
  if (amountNum != null) {
    orderModel.amountNum = amountNum;
  }
  final double? payPrice = jsonConvert.convert<double>(json['pay_price']);
  if (payPrice != null) {
    orderModel.payPrice = payPrice;
  }
  final int? rewardPoints = jsonConvert.convert<int>(json['reward_points']);
  if (rewardPoints != null) {
    orderModel.rewardPoints = rewardPoints;
  }
  final String? receivedAt = jsonConvert.convert<String>(json['received_at']);
  if (receivedAt != null) {
    orderModel.receivedAt = receivedAt;
  }
  final String? grantAt = jsonConvert.convert<String>(json['grant_at']);
  if (grantAt != null) {
    orderModel.grantAt = grantAt;
  }
  final String? pickupCode = jsonConvert.convert<String>(json['pickup_code']);
  if (pickupCode != null) {
    orderModel.pickupCode = pickupCode;
  }
  final String? expressCom = jsonConvert.convert<String>(json['express_com']);
  if (expressCom != null) {
    orderModel.expressCom = expressCom;
  }
  final String? expressNu = jsonConvert.convert<String>(json['express_nu']);
  if (expressNu != null) {
    orderModel.expressNu = expressNu;
  }
  final OrderDetail? detail = jsonConvert.convert<OrderDetail>(json['detail']);
  if (detail != null) {
    orderModel.detail = detail;
  }
  final ExpressModel? express = jsonConvert.convert<ExpressModel>(json['express']);
  if (express != null) {
    orderModel.express = express;
  }
  final OrderAddress? address = jsonConvert.convert<OrderAddress>(json['address']);
  if (address != null) {
    orderModel.address = address;
  }
  final OrderShop? shop = jsonConvert.convert<OrderShop>(json['shop']);
  if (shop != null) {
    orderModel.shop = shop;
  }
  final bool? showAddress = jsonConvert.convert<bool>(json['showAddress']);
  if (showAddress != null) {
    orderModel.showAddress = showAddress;
  }
  return orderModel;
}

Map<String, dynamic> $OrderModelToJson(OrderModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['order_no'] = entity.orderNo;
  data['quantity'] = entity.quantity;
  data['total_price'] = entity.totalPrice;
  data['status'] = entity.status;
  data['refund_status'] = entity.refundStatus;
  data['created_at'] = entity.createdAt;
  data['freight'] = entity.freight;
  data['points_num'] = entity.pointsNum;
  data['points_price'] = entity.pointsPrice;
  data['amount_num'] = entity.amountNum;
  data['pay_price'] = entity.payPrice;
  data['reward_points'] = entity.rewardPoints;
  data['received_at'] = entity.receivedAt;
  data['grant_at'] = entity.grantAt;
  data['pickup_code'] = entity.pickupCode;
  data['express_com'] = entity.expressCom;
  data['express_nu'] = entity.expressNu;
  data['detail'] = entity.detail?.toJson();
  data['express'] = entity.express?.toJson();
  data['address'] = entity.address?.toJson();
  data['shop'] = entity.shop?.toJson();
  data['showAddress'] = entity.showAddress;
  return data;
}

extension OrderModelExtension on OrderModel {
  OrderModel copyWith({
    int? id,
    String? orderNo,
    int? quantity,
    double? totalPrice,
    String? status,
    int? refundStatus,
    String? createdAt,
    double? freight,
    int? pointsNum,
    int? pointsPrice,
    double? amountNum,
    double? payPrice,
    int? rewardPoints,
    String? receivedAt,
    String? grantAt,
    String? pickupCode,
    String? expressCom,
    String? expressNu,
    OrderDetail? detail,
    ExpressModel? express,
    OrderAddress? address,
    OrderShop? shop,
    bool? showAddress,
  }) {
    return OrderModel()
      ..id = id ?? this.id
      ..orderNo = orderNo ?? this.orderNo
      ..quantity = quantity ?? this.quantity
      ..totalPrice = totalPrice ?? this.totalPrice
      ..status = status ?? this.status
      ..refundStatus = refundStatus ?? this.refundStatus
      ..createdAt = createdAt ?? this.createdAt
      ..freight = freight ?? this.freight
      ..pointsNum = pointsNum ?? this.pointsNum
      ..pointsPrice = pointsPrice ?? this.pointsPrice
      ..amountNum = amountNum ?? this.amountNum
      ..payPrice = payPrice ?? this.payPrice
      ..rewardPoints = rewardPoints ?? this.rewardPoints
      ..receivedAt = receivedAt ?? this.receivedAt
      ..grantAt = grantAt ?? this.grantAt
      ..pickupCode = pickupCode ?? this.pickupCode
      ..expressCom = expressCom ?? this.expressCom
      ..expressNu = expressNu ?? this.expressNu
      ..detail = detail ?? this.detail
      ..express = express ?? this.express
      ..address = address ?? this.address
      ..shop = shop ?? this.shop
      ..showAddress = showAddress ?? this.showAddress;
  }
}

OrderDetail $OrderDetailFromJson(Map<String, dynamic> json) {
  final OrderDetail orderDetail = OrderDetail();
  final int? productId = jsonConvert.convert<int>(json['product_id']);
  if (productId != null) {
    orderDetail.productId = productId;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    orderDetail.quantity = quantity;
  }
  final OrderDetailProduct? product = jsonConvert.convert<OrderDetailProduct>(json['product']);
  if (product != null) {
    orderDetail.product = product;
  }
  return orderDetail;
}

Map<String, dynamic> $OrderDetailToJson(OrderDetail entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['product_id'] = entity.productId;
  data['quantity'] = entity.quantity;
  data['product'] = entity.product?.toJson();
  return data;
}

extension OrderDetailExtension on OrderDetail {
  OrderDetail copyWith({
    int? productId,
    int? quantity,
    OrderDetailProduct? product,
  }) {
    return OrderDetail()
      ..productId = productId ?? this.productId
      ..quantity = quantity ?? this.quantity
      ..product = product ?? this.product;
  }
}

OrderDetailProduct $OrderDetailProductFromJson(Map<String, dynamic> json) {
  final OrderDetailProduct orderDetailProduct = OrderDetailProduct();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    orderDetailProduct.name = name;
  }
  final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  if (coverImage != null) {
    orderDetailProduct.coverImage = coverImage;
  }
  final double? price = jsonConvert.convert<double>(json['price']);
  if (price != null) {
    orderDetailProduct.price = price;
  }
  final int? pointsPrice = jsonConvert.convert<int>(json['points_price']);
  if (pointsPrice != null) {
    orderDetailProduct.pointsPrice = pointsPrice;
  }
  final double? marketPrice = jsonConvert.convert<double>(json['market_price']);
  if (marketPrice != null) {
    orderDetailProduct.marketPrice = marketPrice;
  }
  final int? rewardPoints = jsonConvert.convert<int>(json['reward_points']);
  if (rewardPoints != null) {
    orderDetailProduct.rewardPoints = rewardPoints;
  }
  final double? freight = jsonConvert.convert<double>(json['freight']);
  if (freight != null) {
    orderDetailProduct.freight = freight;
  }
  return orderDetailProduct;
}

Map<String, dynamic> $OrderDetailProductToJson(OrderDetailProduct entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['cover_image'] = entity.coverImage;
  data['price'] = entity.price;
  data['points_price'] = entity.pointsPrice;
  data['market_price'] = entity.marketPrice;
  data['reward_points'] = entity.rewardPoints;
  data['freight'] = entity.freight;
  return data;
}

extension OrderDetailProductExtension on OrderDetailProduct {
  OrderDetailProduct copyWith({
    String? name,
    String? coverImage,
    double? price,
    int? pointsPrice,
    double? marketPrice,
    int? rewardPoints,
    double? freight,
  }) {
    return OrderDetailProduct()
      ..name = name ?? this.name
      ..coverImage = coverImage ?? this.coverImage
      ..price = price ?? this.price
      ..pointsPrice = pointsPrice ?? this.pointsPrice
      ..marketPrice = marketPrice ?? this.marketPrice
      ..rewardPoints = rewardPoints ?? this.rewardPoints
      ..freight = freight ?? this.freight;
  }
}

OrderAddress $OrderAddressFromJson(Map<String, dynamic> json) {
  final OrderAddress orderAddress = OrderAddress();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    orderAddress.id = id;
  }
  final int? userId = jsonConvert.convert<int>(json['user_id']);
  if (userId != null) {
    orderAddress.userId = userId;
  }
  final String? sex = jsonConvert.convert<String>(json['sex']);
  if (sex != null) {
    orderAddress.sex = sex;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    orderAddress.name = name;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    orderAddress.phone = phone;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    orderAddress.address = address;
  }
  final String? houseNumber = jsonConvert.convert<String>(json['house_number']);
  if (houseNumber != null) {
    orderAddress.houseNumber = houseNumber;
  }
  final int? isDefault = jsonConvert.convert<int>(json['is_default']);
  if (isDefault != null) {
    orderAddress.isDefault = isDefault;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    orderAddress.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    orderAddress.updatedAt = updatedAt;
  }
  return orderAddress;
}

Map<String, dynamic> $OrderAddressToJson(OrderAddress entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['sex'] = entity.sex;
  data['name'] = entity.name;
  data['phone'] = entity.phone;
  data['address'] = entity.address;
  data['house_number'] = entity.houseNumber;
  data['is_default'] = entity.isDefault;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension OrderAddressExtension on OrderAddress {
  OrderAddress copyWith({
    int? id,
    int? userId,
    String? sex,
    String? name,
    String? phone,
    String? address,
    String? houseNumber,
    int? isDefault,
    String? createdAt,
    String? updatedAt,
  }) {
    return OrderAddress()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..sex = sex ?? this.sex
      ..name = name ?? this.name
      ..phone = phone ?? this.phone
      ..address = address ?? this.address
      ..houseNumber = houseNumber ?? this.houseNumber
      ..isDefault = isDefault ?? this.isDefault
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}

OrderShop $OrderShopFromJson(Map<String, dynamic> json) {
  final OrderShop orderShop = OrderShop();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    orderShop.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    orderShop.name = name;
  }
  final String? logoUrl = jsonConvert.convert<String>(json['logo_url']);
  if (logoUrl != null) {
    orderShop.logoUrl = logoUrl;
  }
  return orderShop;
}

Map<String, dynamic> $OrderShopToJson(OrderShop entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['logo_url'] = entity.logoUrl;
  return data;
}

extension OrderShopExtension on OrderShop {
  OrderShop copyWith({
    int? id,
    String? name,
    String? logoUrl,
  }) {
    return OrderShop()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..logoUrl = logoUrl ?? this.logoUrl;
  }
}

ExpressModel $ExpressModelFromJson(Map<String, dynamic> json) {
  final ExpressModel expressModel = ExpressModel();
  final String? showApiResError = jsonConvert.convert<String>(json['showapi_res_error']);
  if (showApiResError != null) {
    expressModel.showApiResError = showApiResError;
  }
  final int? showApiFeeNum = jsonConvert.convert<int>(json['showapi_fee_num']);
  if (showApiFeeNum != null) {
    expressModel.showApiFeeNum = showApiFeeNum;
  }
  final int? showApiResCode = jsonConvert.convert<int>(json['showapi_res_code']);
  if (showApiResCode != null) {
    expressModel.showApiResCode = showApiResCode;
  }
  final String? showApiResId = jsonConvert.convert<String>(json['showapi_res_id']);
  if (showApiResId != null) {
    expressModel.showApiResId = showApiResId;
  }
  final ExpressDetail? expressDetail = jsonConvert.convert<ExpressDetail>(json['showapi_res_body']);
  if (expressDetail != null) {
    expressModel.expressDetail = expressDetail;
  }
  return expressModel;
}

Map<String, dynamic> $ExpressModelToJson(ExpressModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['showapi_res_error'] = entity.showApiResError;
  data['showapi_fee_num'] = entity.showApiFeeNum;
  data['showapi_res_code'] = entity.showApiResCode;
  data['showapi_res_id'] = entity.showApiResId;
  data['showapi_res_body'] = entity.expressDetail?.toJson();
  return data;
}

extension ExpressModelExtension on ExpressModel {
  ExpressModel copyWith({
    String? showApiResError,
    int? showApiFeeNum,
    int? showApiResCode,
    String? showApiResId,
    ExpressDetail? expressDetail,
  }) {
    return ExpressModel()
      ..showApiResError = showApiResError ?? this.showApiResError
      ..showApiFeeNum = showApiFeeNum ?? this.showApiFeeNum
      ..showApiResCode = showApiResCode ?? this.showApiResCode
      ..showApiResId = showApiResId ?? this.showApiResId
      ..expressDetail = expressDetail ?? this.expressDetail;
  }
}

ExpressDetail $ExpressDetailFromJson(Map<String, dynamic> json) {
  final ExpressDetail expressDetail = ExpressDetail();
  final int? update = jsonConvert.convert<int>(json['update']);
  if (update != null) {
    expressDetail.update = update;
  }
  final String? upgradeInfo = jsonConvert.convert<String>(json['upgrade_info']);
  if (upgradeInfo != null) {
    expressDetail.upgradeInfo = upgradeInfo;
  }
  final String? updateStr = jsonConvert.convert<String>(json['updateStr']);
  if (updateStr != null) {
    expressDetail.updateStr = updateStr;
  }
  final String? logo = jsonConvert.convert<String>(json['logo']);
  if (logo != null) {
    expressDetail.logo = logo;
  }
  final int? dataSize = jsonConvert.convert<int>(json['dataSize']);
  if (dataSize != null) {
    expressDetail.dataSize = dataSize;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    expressDetail.status = status;
  }
  final int? feeNum = jsonConvert.convert<int>(json['fee_num']);
  if (feeNum != null) {
    expressDetail.feeNum = feeNum;
  }
  final String? tel = jsonConvert.convert<String>(json['tel']);
  if (tel != null) {
    expressDetail.tel = tel;
  }
  final List<ExpressDetailData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ExpressDetailData>(e) as ExpressDetailData).toList();
  if (data != null) {
    expressDetail.data = data;
  }
  final String? expSpellName = jsonConvert.convert<String>(json['expSpellName']);
  if (expSpellName != null) {
    expressDetail.expSpellName = expSpellName;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    expressDetail.msg = msg;
  }
  final String? mailNo = jsonConvert.convert<String>(json['mailNo']);
  if (mailNo != null) {
    expressDetail.mailNo = mailNo;
  }
  final int? queryTimes = jsonConvert.convert<int>(json['queryTimes']);
  if (queryTimes != null) {
    expressDetail.queryTimes = queryTimes;
  }
  final int? retCode = jsonConvert.convert<int>(json['ret_code']);
  if (retCode != null) {
    expressDetail.retCode = retCode;
  }
  final bool? flag = jsonConvert.convert<bool>(json['flag']);
  if (flag != null) {
    expressDetail.flag = flag;
  }
  final String? expTextName = jsonConvert.convert<String>(json['expTextName']);
  if (expTextName != null) {
    expressDetail.expTextName = expTextName;
  }
  final dynamic possibleExpList = json['possibleExpList'];
  if (possibleExpList != null) {
    expressDetail.possibleExpList = possibleExpList;
  }
  return expressDetail;
}

Map<String, dynamic> $ExpressDetailToJson(ExpressDetail entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['update'] = entity.update;
  data['upgrade_info'] = entity.upgradeInfo;
  data['updateStr'] = entity.updateStr;
  data['logo'] = entity.logo;
  data['dataSize'] = entity.dataSize;
  data['status'] = entity.status;
  data['fee_num'] = entity.feeNum;
  data['tel'] = entity.tel;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['expSpellName'] = entity.expSpellName;
  data['msg'] = entity.msg;
  data['mailNo'] = entity.mailNo;
  data['queryTimes'] = entity.queryTimes;
  data['ret_code'] = entity.retCode;
  data['flag'] = entity.flag;
  data['expTextName'] = entity.expTextName;
  data['possibleExpList'] = entity.possibleExpList;
  return data;
}

extension ExpressDetailExtension on ExpressDetail {
  ExpressDetail copyWith({
    int? update,
    String? upgradeInfo,
    String? updateStr,
    String? logo,
    int? dataSize,
    int? status,
    int? feeNum,
    String? tel,
    List<ExpressDetailData>? data,
    String? expSpellName,
    String? msg,
    String? mailNo,
    int? queryTimes,
    int? retCode,
    bool? flag,
    String? expTextName,
    dynamic possibleExpList,
  }) {
    return ExpressDetail()
      ..update = update ?? this.update
      ..upgradeInfo = upgradeInfo ?? this.upgradeInfo
      ..updateStr = updateStr ?? this.updateStr
      ..logo = logo ?? this.logo
      ..dataSize = dataSize ?? this.dataSize
      ..status = status ?? this.status
      ..feeNum = feeNum ?? this.feeNum
      ..tel = tel ?? this.tel
      ..data = data ?? this.data
      ..expSpellName = expSpellName ?? this.expSpellName
      ..msg = msg ?? this.msg
      ..mailNo = mailNo ?? this.mailNo
      ..queryTimes = queryTimes ?? this.queryTimes
      ..retCode = retCode ?? this.retCode
      ..flag = flag ?? this.flag
      ..expTextName = expTextName ?? this.expTextName
      ..possibleExpList = possibleExpList ?? this.possibleExpList;
  }
}

ExpressDetailData $ExpressDetailDataFromJson(Map<String, dynamic> json) {
  final ExpressDetailData expressDetailData = ExpressDetailData();
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    expressDetailData.time = time;
  }
  final String? context = jsonConvert.convert<String>(json['context']);
  if (context != null) {
    expressDetailData.context = context;
  }
  return expressDetailData;
}

Map<String, dynamic> $ExpressDetailDataToJson(ExpressDetailData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['time'] = entity.time;
  data['context'] = entity.context;
  return data;
}

extension ExpressDetailDataExtension on ExpressDetailData {
  ExpressDetailData copyWith({
    String? time,
    String? context,
  }) {
    return ExpressDetailData()
      ..time = time ?? this.time
      ..context = context ?? this.context;
  }
}